package sy.model;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
@Table(name = "app_plant", catalog = "ssh")
public class AppPlant implements java.io.Serializable{
	private String id;
	private String code;
	private String name;
	private String category;
	private SysProject sysProject;
	private String status;
	private BigDecimal price;
	private Date prodDate;
	private String descriptions;
	private String type;
	private String latitude;
	private String longitude;
	
	@JsonProperty(value = "projectName")
    private String projectName;

	public AppPlant() {
		super();
	}
	
	@GenericGenerator(name = "generator", strategy = "uuid.string")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 64)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}
	@Column(name = "code", unique = true, nullable = false)
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "category")
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "sysProject")
	public SysProject getSysProject() {
		return sysProject;
	}
	public void setSysProject(SysProject sysProject) {
		this.sysProject = sysProject;
	}

	@Column(name = "status")
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "price")
	public BigDecimal getPrice() {
		return price;
	}
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	@Column(name = "prod_date")
	public Date getProdDate() {
		return prodDate;
	}
	public void setProdDate(Date prodDate) {
		this.prodDate = prodDate;
	}
	@Column(name = "descriptions")
	public String getDescriptions() {
		return descriptions;
	}
	@Column(name = "type")
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "latitude")
	public String getLatitude() {
		return latitude;
	}
	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
	@Column(name = "longitude")
	public String getLongitude() {
		return longitude;
	}
	public void setDescriptions(String descriptions) {
		this.descriptions = descriptions;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	
	@Transient
    public String getProjectName() {
    	return getSysProject()!=null?getSysProject().getName():"";
	}
	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}
}
